package com.blb.productservice.controller;

import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.blb.common.entity.Product;
import com.blb.common.util.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PathVariable;

@Slf4j
public class HelloControllerBlockHandler {

    /**
     * 限流处理
     * @return
     */
    public static String helloBlockHandler(BlockException ex){
        log.error("出现限流",ex);
        return "Hello 我被限流了：(";
    }

    public static ResponseResult<Product> getProductByIdBlockHandler(@PathVariable Long id,BlockException ex){
        log.error("出现限流",ex);
        Product data = new Product();
        data.setName("限流处理");
        return ResponseResult.ok(data);
    }
}
